package edu.the.last.modell;

import java.util.Arrays;

import javax.sound.sampled.AudioFormat;

public class Music {
	private int bpm, bpb;// bpm = beat/minute; bpb =
	// beat/bar
	private byte audioBytes[];
	private int notes[];
	private String chords[];
	private AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100, 8, 1, 1, 44100, true);

	/**
	 * @param bpm
	 * @param bpb
	 * @param interval
	 */
	public Music(int bpm, int bpb) {
		this.bpm = bpm;
		this.bpb = bpb;
	}

	/**
	 * @param bpm
	 * @param bpb
	 * @param audioBytes
	 * @param notes
	 * @param chords
	 */
	public Music(int bpm, int bpb, byte[] audioBytes, int[] notes, String[] chords) {
		this.bpm = bpm;
		this.bpb = bpb;
		this.audioBytes = Arrays.copyOf(audioBytes, audioBytes.length);
		this.notes = Arrays.copyOf(notes, notes.length);
		this.chords = Arrays.copyOf(chords, chords.length);
	}

	/**
	 * @return the bpm (beat/minute(
	 */
	public int getBpm() {
		return bpm;
	}

	/**
	 * @param bpm (beat/minute(
	 *            the bpm to set
	 */
	public void setBpm(int bpm) {
		this.bpm = bpm;
	}
	
	/**
	 * @return the bpb (beat/bar)
	 */
	public int getBpb() {
		return bpb;
	}

	/**
	 * @param bpb  (beat/bar)
	 *            the bpb to set
	 */
	public void setBpb(int bpb) {
		this.bpb = bpb;
	}
	/**
	 * @return the interval for sound in which to detect a sound
	 */
	public double getInterval() {
		return 30.0/bpm;
	}

	/**
	 * @return the audioBytes
	 */
	public byte[] getAudioBytes() {
		return audioBytes;
	}

	/**
	 * @param audioBytes
	 *            the audioBytes to set
	 */
	public void setAudioBytes(byte[] audioBytes) {
		this.audioBytes = Arrays.copyOf(audioBytes, audioBytes.length);
	}

	/**
	 * @return the notes
	 */
	public int[] getNotes() {
		return notes;
	}

	/**
	 * @param notes
	 *            the notes to set
	 */
	public void setNotes(int[] notes) {
		this.notes = Arrays.copyOf(notes, notes.length);
	}

	/**
	 * @return the chords
	 */
	public String[] getChords() {
		return chords;
	}

	/**
	 * @param chords
	 *            the chords to set
	 */
	public void setChords(String[] chords) {
		this.chords = Arrays.copyOf(chords, chords.length);
	}

	/**
	 * @return the format
	 */
	public AudioFormat getFormat() {
		return format;
	}

	/**
	 * @param format
	 *            the format to set
	 */
	public void setFormat(AudioFormat format) {
		this.format = format;
	}

	public void clear() {
		audioBytes = null;
		notes = null;
		chords = null;
	}
}
